#!/bin/bash
SERVICE_NAME="spring-jdbc-demo-1.0-SNAPSHOT.jar"
LOG_FILE="nohup.out"
start_service() {
  PID=$(ps -ef | grep "java -jar $SERVICE_NAME" | grep -v grep | awk '{print $3}')
  if [ -n "$PID" ]; then
    echo "Service is already running."
  else
    echo "开始启动"
    nohup java -jar $SERVICE_NAME > $LOG_FILE 2>&1 &
    echo "Service started."
  fi
}

stop_service() {
  PID=$(ps -ef | grep "java -jar $SERVICE_NAME" | grep -v grep | awk '{print $2}')
  if [ -n "$PID" ]; then
    kill $PID
    echo "Service stopped."
  else
    echo "Service is not running."
  fi
  }